package wci.backend;

import java.io.*;

import wci.intermediate.ICode;
import wci.intermediate.SymTabStack;

/**
 * <h1>Backend</h1>
 *
 * <p>The framework class that represents the back end component.</p>
 *
 * <p>Copyright (c) 2008 by Ronald Mak</p>
 * <p>For instructional purposes only.  No warranties.</p>
 */
public abstract class Backend
{
    protected SymTabStack symTabStack;  // symbol table stack
    protected ICode iCode;              // intermediate code

    /**
     * Getter.
     * @return the intermediate code generated by this parser.
     */
    public ICode getICode()
    {
        return iCode;
    }

    /**
     * Getter.
     * @return the symbol table stack.
     */
    public SymTabStack getSymTabStack()
    {
        return symTabStack;
    }

    /**
     * Process the intermediate code and the symbol table generated by the
     * parser.  To be implemented by a compiler or an interpreter subclass.
     * @param iCode the intermediate code.
     * @param symTabStack the symbol table stack.
     * @param objectFilePath the object file path for the generated code.
     * @throws Exception if an error occurred.
     */
    public abstract void process(ICode iCode, SymTabStack symTabStack,
                                 String objectFilePath)
        throws Exception;
}
